package com.ycz.master.Test;

public class myList {
    private Node head;
    private int size;

    static class Node {
        String value;
        Node next;

        public Node(String value) {
            this.value = value;
        }
    }

    public myList() {
    }

    public void add(String value) {
        Node node2=new Node(value);
        Node node = head;
        while (node.next != null) {
            node = node.next;
        }
        node.next = node2;
    }

    public void add(String value, int position) {
        Node node = new Node(value);
        if (position < 1 || position > size + 1) {
            return;
        }
        int length = 1;
        Node temp = head;
        while (head.next != null) {
            if (position == length++) {
                node.next = temp.next;
                temp.next = node;
                return;
            }
            temp = temp.next;
        }
    }
}